class Solution {
public:
    int maxArea(vector<int>& h) {
        int l = 0;
        int r = h.size() - 1;
        int ma = 0;
        while (l != r) {
            int x = (r - l) * min(h[l], h[r]);
            ma = max(ma, x);
            if (h[l] < h[r])l++;
            else r--;
        }
        return ma;
    }
};